﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameBase;
using Microsoft.Xna.Framework;

namespace GalaxyPresident
{
    public enum InfomationType { None, Brief, Full }
    class SolarSystemView : Visble3DObject
    {
        InfomationType showInfo = InfomationType.None;
        SolarSystem solarSystem;
        static Sprite glowSprite= new Sprite(@"Resources/solarsystem_g", 1, 1);

        public InfomationType ShowInfo
        {
            get { return showInfo; }
            set { showInfo = value; }
        }
        public SolarSystem SolarSystem
        {
            get { return solarSystem; }
            set { solarSystem = value; }
        }
        
        public SolarSystemView(SolarSystem ss)
        {
            Scale = ss.Size;
            solarSystem = ss;
            sprite = new Sprite(@"Resources/solarSystem", 2, 2);
            sprite.Color = ss.Color;
            sprite.FrameSequence = new List<int> { 0, 1, 2, 3, 2, 1 };
            sprite.CurrentFrame = Constant.random.Next(6);
            sprite.Delay = Constant.random.Next(50) + 50;
            sprite.SetOriginPosition(ORIGIN_POSITION.Center);


            //glowSprite ;
            glowSprite.SetOriginPosition(ORIGIN_POSITION.Center);
            Position3D = SolarSystem.Position;
            
        }
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Update(gameTime);
            Position3D = SolarSystem.Position;
        }
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Microsoft.Xna.Framework.Vector3 position)
        {
            //base.Draw(gameTime, spriteBatch, position);
            if (z >= maxDepth)
                return;

            Vector2 pos = new Vector2(position.X, position.Y);
            float rotate = GetDrawRotate();
            float drawScale = GetDrawScale();
            float depth = GetDrawDepth();

            Sprite.Draw(gameTime, spriteBatch,
               pos, rotate, drawScale, depth);
            glowSprite.Draw(gameTime, spriteBatch,
               pos, rotate, drawScale, depth - 0.00001f);

            if (ShowInfo == InfomationType.Brief)
            {
                Text.Draw(spriteBatch, SolarSystem.Name, Constant.fontNormal,
                    position.X + 60 * GetDrawScale(), position.Y - 60 * GetDrawScale());
                
            }
            else if (ShowInfo == InfomationType.Full)
            {
                
                Text.Draw(spriteBatch, SolarSystem.Name, Constant.fontNormalBold,
                    position.X + 60 * GetDrawScale(), position.Y - 60 * GetDrawScale());
                Text.Draw(spriteBatch, SolarSystem.Position.ToString(), Constant.fontSmall,
                    position.X + 60 * GetDrawScale(), position.Y - 60 * GetDrawScale()+30);

                Text.Draw(spriteBatch, "No. planets : "+SolarSystem.Planets.Count,
                    Constant.fontSmall,
                    position.X + 60 * GetDrawScale(), position.Y - 60 * GetDrawScale() + 50);

                /*Text.Draw(spriteBatch, SolarSystem.Position.ToString(), Constant.fontSmall,
                    position.X + 60 * GetDrawScale(), position.Y - 60 * GetDrawScale() + 80);*/
            }
        } 
    }
}
